<?php
class Silk_Sites extends Silk_Gateway
{

    protected $_dao_class = 'Silk_Dao_Site';

    protected $_model_class = 'Silk_Site';

    protected $_primary_key = 'site_id';

    public function postSave(array $pData){
	$permission_name = "Site {$pData['site_id']} Manage";
	$permission_resource = "site.{$pData['site_id']}";
	$permission_privilege = PERMISSION_MANAGE;
	$permission_roles = array("Administrator");

	if (Silk::HasIdentity()){
	    $permission_roles[] = Silk::GetIdentity();
	}

	Silk::CreatePermission(
	    $permission_name,
	    $permission_resource,
	    $permission_privilege,
	    $permission_roles
	);

	return $pData;
    }

    public function getObjects($pSite)
    {
        $site_id = $this->getModelObjectId($pSite);

        $Objects = new Silk_Objects();

        return $Objects->getObjectsForSite($site_id);
    }

    public function getMetas($pSite)
    {
        $site_id = $this->getModelObjectId($pSite);

        $Metas = new Silk_Metas();

        return $Metas->getMetasForSite($site_id);
    }

    public function getTranslations($pSite)
    {
        $site_id = $this->getModelObjectId($pSite);

        $Translations = new Silk_Translations();

        return $Translations->getTranslationsForSite($site_id);
    }

    public function getRoutes($pSite)
    {
        $site_id = $this->getModelObjectId($pSite);

        $Routes = new Silk_Routes();

        return $Routes->getRoutesForSite($site_id);
    }

    public function getTerms($pSite)
    {
        $site_id = $this->getModelObjectId($pSite);

        $Terms = new Silk_Terms();

        return $Terms->getTermsForSite($site_id);
    }

    public function getTermTaxonomies($pSite)
    {
        $site_id = $this->getModelObjectId($pSite);

        $TermTaxonomys = new Silk_TermTaxonomys();

        return $TermTaxonomys->getTermTaxonomysForSite($site_id);
    }

    public function getTypes($pSite)
    {
        $site_id = $this->getModelObjectId($pSite);

        $ObjectTypes = new Silk_ObjectTypes();

        return $ObjectTypes->getObjectTypesForSite($site_id);
    }


}

 ?>